
#include <string.h>

#include "xapp_event_send.h"


typedef struct
{
    custom_event_handle_callback_t list[2];
    uint32_t cnt; 
}custom_event_notify_t;

static custom_event_notify_t event_centor = {.cnt = 0};

//void xapp_event_send_init(void)
//{
//    event_centor.cnt = 0;
//}

void xapp_event_send_register_handler(custom_event_handle_callback_t cb)
{
    for(int i = 0; i < event_centor.cnt ; i ++ )
    {
        if( event_centor.list[i] == cb ) 
        {
            return;
        }
    }
    
    event_centor.list[event_centor.cnt ++] = cb;
}


void xapp_event_send( custom_evt_t* p_evt)
{
    for(int i = 0; i < event_centor.cnt; i ++)
    {
        if( event_centor.list[i] != NULL )
        {
            event_centor.list[i]((void*)p_evt );
        }
    }
}
